package com.yanqu.road.server.manager.cookboy;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.cookboy.CookBoyConfig;
import com.yanqu.road.entity.activity.cookboy.process2.CookBoy2DishConfig;
import com.yanqu.road.entity.activity.cookboy.process2.CookBoy2Spoon;
import com.yanqu.road.entity.activity.cookboy.process3.CookBoy3OpenItem;
import com.yanqu.road.entity.enums.activity.eActivityCookBoyType;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.logic.bussiness.servercenter.ActivityBussiness;
import com.yanqu.road.server.manager.activity.CrossRelationActivityMgr;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class CrossCookBoyActivityMgr extends CrossRelationActivityMgr {

    private Logger logger = LogManager.getLogger(CrossCookBoyActivityMgr.class.getName());

    protected static RandomHelper randomHelper = new RandomHelper();


    public static final String COOKBOY_SERVE_FOOD_DAY_START = "10";//每天开始比赛时间小时
    public static final String COOKBOY_SERVE_FOOD_DAY_END = "22";//每天结束比赛时间小时
    public static final String COOKBOY_PARTICPATE_COOKING_MAX_NUM = "50";//总共可以上多少菜
    public static final String COOKBOY_PARTICPATE_COOKING_SINGLE_MAX_NUM = "30";//一个人可以上多少菜
    public static final String COOKBOY_PARTICPATE_COOKING_TIME = "60";//一场比赛进行时间分钟
    public static final String COOKBOY_PARTICPATE_RANK_SCORE = "1;100|2;90|3;80|5;70|20;50|51;0";//参数排行积分：1<=x<2;100|2<=x<3;90…
    public static final String COOKBOY_PARTICPATE_HISTORY_LIMIT = "200";//历史记录下发多少条
    public static final String COOKBOY_EXCHANGE_ITEM_ID = "101967";//历史记录下发多少条
    public static final String COOKBOY_TO_COOKBOY2_RANK = "10";//阶段1晋级阶段2排名


    //小当家第二阶段
    public static final String COOKBOY2_SWITCH = "1";//是否开启凭证参与
    public static final String COOKBOY2_CERTIFICATE_CONSUME = "120466=1";//参与活动需要消耗的凭证道具
    public static final String COOKBOY2_EXCHANGE_ITEM_ID = "101968";//积分道具
    public static final String COOKBOY2_RESTORE_ITEM_ID = "120462";//恢复体力道具ID，恢复值在道具参数1中
    public static final String COOKBOY2_ENERGY_PARAM = "30;30";//初始体力，体力上限
    public static final String COOKBOY2_ENERGY_CD_TIME = "10";//体力恢复一点时间(秒)
    public static final String COOKBOY2_PICK_DISH_REWARDS = "110000=1;20|110001=1;30";//挑菜随机奖励列表,道具=道具数量;权重
    public static final String COOKBOY2_TRY_DISH_CONFIG = "120463=1;100;100|120464=1;200;200|120465=1;300;300";//赴宴试吃消耗道具和数量;试吃获得积分;开宴获得积分
    public static final String COOKBOY2_WORSHIP_REWARDS = "101000=200";//膜拜奖励列表
    public static final String COOKBOY2_PARTICPATE_COOKING_TIME = "60";//试吃单场时长(分)
    public static final String COOKBOY2_PARTICPATE_COOKING_TABLE = "2";//试吃每人可以开启多少道菜
    public static final String COOKBOY2_SERVE_FOOD_DAY_START = "10";
    public static final String COOKBOY2_SERVE_FOOD_DAY_END = "22";
    public static final String COOKBOY2_ROBOT_ADD = "1000";//机器人填补座位加成积分千分比
    public static final String COOKBOY2_TO_COOKBOY3_RANK = "10";//阶段2晋级阶段3排名
    public static final String COOKBOY2_ROBOTS_APPEARENCE_LIST = "123500;123501;123502;123503;123504;123505;123506";//机器人

    //小当家第三阶段
    public static final String COOKBOY3_SWITCH	 =  "1"; //是否开启凭证参与
    public static final String COOKBOY3_CERTIFICATE_CONSUME	="120467=1";//参与活动需要消耗的凭证道具
    public static final String COOKBOY3_EXCHANGE_ITEM_ID	="101969";//兑换商店积分道具ID
    public static final String COOKBOY3_BANQUET_OPEN_CONFIG	="120468=1;50;60;20|120469=1;100;120;25|120470=1;150;180;30";//开宴道具消耗、试吃人数、持续时间(分)、赴宴人赴宴给开宴人增加的积分
    public static final String COOKBOY3_JOIN_BANQUET_REWARD	="121068=1|121069=1|121070=1";//赴宴奖励宝箱ID，区分不同宴会
    public static final String COOKBOY3_JOIN_BANQUET_SCORE	="100";//赴宴试吃增加的宴会积分
    public static final String COOKBOY3_SERVE_FOOD_DAY_START	="10";//每天开始比赛时间小时
    public static final String COOKBOY3_SERVE_FOOD_DAY_END	="22";//每天结束比赛时间小时
    public static final String COOKBOY3_WORSHIP_REWARDS	="101000=200";//膜拜奖励列表
    public static final String COOKBOY3_ROBOT_ADD = "1000";//机器人填补座位加成积分千分比


    private static Map<Integer,ActivityInfo> activityInfoMap = new ConcurrentHashMap<>();

    //活动config配置
    protected static Map<Integer,Map<String,CookBoyConfig>> cookBoyConfigMap = new ConcurrentHashMap<>();

    //阶段2菜品配置
    private static Map<Integer, Map<Integer, CookBoy2DishConfig>> cookBoyDishConfigMap = new ConcurrentHashMap<>();


    public CrossCookBoyActivityMgr(){
//		reload();
    }

    public static int getRandomCookBoy2Robot(int activityId){
        String rebotStr = COOKBOY2_ROBOTS_APPEARENCE_LIST;
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_ROBOTS_APPEARENCE_LIST")){
                rebotStr = configMap.get("COOKBOY2_ROBOTS_APPEARENCE_LIST").getValue();
            }
        }
        List<Integer> robotIdList = StringUtils.stringToIntegerList(rebotStr,";");
        int randomNum = randomHelper.next(0, robotIdList.size());
        return robotIdList.get(randomNum);
    }

    public static int getCook1ToCook2Rank(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_TO_COOKBOY2_RANK")){
                return Integer.valueOf(configMap.get("COOKBOY_TO_COOKBOY2_RANK").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_TO_COOKBOY2_RANK);
    }

    public static int getCook2ToCook3Rank(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_TO_COOKBOY3_RANK")){
                return Integer.valueOf(configMap.get("COOKBOY2_TO_COOKBOY3_RANK").getValue());
            }
        }
        return Integer.valueOf(COOKBOY2_TO_COOKBOY3_RANK);
    }

    public static int getCookBoy3RobotAdd(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY3_ROBOT_ADD")){
                return Integer.valueOf(configMap.get("COOKBOY3_ROBOT_ADD").getValue());
            }
        }
        return Integer.valueOf(COOKBOY3_ROBOT_ADD);
    }

    public static int getCookBoy2RobotAdd(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_ROBOT_ADD")){
                return Integer.valueOf(configMap.get("COOKBOY2_ROBOT_ADD").getValue());
            }
        }
        return Integer.valueOf(COOKBOY2_ROBOT_ADD);
    }

    public static int getCookBoy3IntegralItemId(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY3_EXCHANGE_ITEM_ID")){
                return Integer.valueOf(configMap.get("COOKBOY3_EXCHANGE_ITEM_ID").getValue());
            }
        }
        return Integer.valueOf(COOKBOY3_EXCHANGE_ITEM_ID);
    }

    public static CookBoy3OpenItem getCookBoy3OpenItem(int activityId, int itemId){
        String strConfig = COOKBOY3_BANQUET_OPEN_CONFIG;
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY3_BANQUET_OPEN_CONFIG")){
                strConfig = configMap.get("COOKBOY3_BANQUET_OPEN_CONFIG").getValue();
            }
        }
        List<String> infoList = StringUtils.stringToStringList(strConfig,"\\|");
        int i = 1;
        for(String info : infoList){
            List<String> itemList = StringUtils.stringToStringList(info,";");
            String consume = itemList.get(0);
            int itemConfigId = StringUtils.stringToIntegerList(consume,"=").get(0);
            if(itemConfigId == itemId){
                CookBoy3OpenItem config = new CookBoy3OpenItem();
                config.setItemId(itemId);
                config.setEatNum(Integer.valueOf(itemList.get(1)));
                config.setMinute(Integer.valueOf(itemList.get(2)));
                config.setIntegral(Long.valueOf(itemList.get(3)));
                config.setPos(i++);
                return config;
            }
        }
        return null;
    }


    public static CookBoy2DishConfig getDishCondfig(int activityId,int dishId){
        if(cookBoyDishConfigMap.containsKey(activityId)){
            if(cookBoyDishConfigMap.get(activityId).containsKey(dishId)){
                return cookBoyDishConfigMap.get(activityId).get(dishId);
            }
        }
        return null;
    }

    public static CookBoy2Spoon getCookBoy2Spoon(int activityId, int spoonId){
        String strConfig = COOKBOY2_TRY_DISH_CONFIG;
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_TRY_DISH_CONFIG")){
                strConfig = configMap.get("COOKBOY2_TRY_DISH_CONFIG").getValue();
            }
        }
        List<String> infoList = StringUtils.stringToStringList(strConfig,"\\|");
        for(String info : infoList){
            List<String> itemList = StringUtils.stringToStringList(info,";");
            String consume = itemList.get(0);
            int itemId = StringUtils.stringToIntegerList(consume,"=").get(0);
            if(itemId == spoonId){
                CookBoy2Spoon cookBoy2Spoon = new CookBoy2Spoon();
                cookBoy2Spoon.setItemId(itemId);
                cookBoy2Spoon.setJoinerIntegral(Long.valueOf(itemList.get(1)));
                cookBoy2Spoon.setUserIntegral(Long.valueOf(itemList.get(2)));
                cookBoy2Spoon.setConsume(consume);
                return cookBoy2Spoon;
            }
        }
        return null;
    }

    /**
     * 获取活动中所有汤勺道具的ID，并从小到大牌组
     *
     * @param activityId 活动ID
     * @return List<Integer>
     */
    public static List<Integer> getCookBoy2SpoonIds(int activityId){
        String strConfig = COOKBOY2_TRY_DISH_CONFIG;
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_TRY_DISH_CONFIG")){
                strConfig = configMap.get("COOKBOY2_TRY_DISH_CONFIG").getValue();
            }
        }
        List<String> infoList = StringUtils.stringToStringList(strConfig,"\\|");
        List<Integer> res = new ArrayList<>();
        for(String info : infoList){
            List<String> itemList = StringUtils.stringToStringList(info,";");
            String consume = itemList.get(0);
            int spoonId = StringUtils.stringToIntegerList(consume,"=").get(0);
            res.add(spoonId);
        }

        Collections.sort(res);
        return res;
    }

    public static CookBoy2Spoon getCookBoy2MinSpoon(int activityId){
        String strConfig = COOKBOY2_TRY_DISH_CONFIG;
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_TRY_DISH_CONFIG")){
                strConfig = configMap.get("COOKBOY2_TRY_DISH_CONFIG").getValue();
            }
        }
        List<String> infoList = StringUtils.stringToStringList(strConfig,"\\|");
        //机器人默认第一个道具赴宴处理
        for(String info : infoList){
            List<String> itemList = StringUtils.stringToStringList(info,";");
            String consume = itemList.get(0);
            int itemId = StringUtils.stringToIntegerList(consume,"=").get(0);
            CookBoy2Spoon cookBoy2Spoon = new CookBoy2Spoon();
            cookBoy2Spoon.setItemId(itemId);
            cookBoy2Spoon.setJoinerIntegral(Long.valueOf(itemList.get(1)));
            cookBoy2Spoon.setUserIntegral(Long.valueOf(itemList.get(2)));
            cookBoy2Spoon.setConsume(consume);
            return cookBoy2Spoon;
        }
        return null;
    }

    public static Map<Integer,Integer> getMatchRankRewardMap(int activityId){
        Map<Integer,Integer> rankIntegralMap = new ConcurrentHashMap<>();
        String org = COOKBOY_PARTICPATE_RANK_SCORE;
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_PARTICPATE_RANK_SCORE")){
                org = configMap.get("COOKBOY_PARTICPATE_RANK_SCORE").getValue();
            }
        }
        List<String> rankInfoList = StringUtils.stringToStringList(org,"\\|");
        for(int i = 0;i < rankInfoList.size() ; i++){
            if(i+1 < rankInfoList.size()){
                List<Integer> rankIntegralList = StringUtils.stringToIntegerList(rankInfoList.get(i),";");
                List<Integer> nextRankIntegralList = StringUtils.stringToIntegerList(rankInfoList.get(i+1),";");
                rankIntegralMap.put(nextRankIntegralList.get(0),rankIntegralList.get(1));
            }
        }
        return rankIntegralMap;
    }

    public static int getCookBoy2OpenTableLimit(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_PARTICPATE_COOKING_TABLE")){
                return Integer.valueOf(configMap.get("COOKBOY2_PARTICPATE_COOKING_TABLE").getValue());
            }
        }
        return Integer.valueOf(COOKBOY2_PARTICPATE_COOKING_TABLE);
    }

    public static int getHistoryMatchLimit(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_PARTICPATE_HISTORY_LIMIT")){
                return Integer.valueOf(configMap.get("COOKBOY_PARTICPATE_HISTORY_LIMIT").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_PARTICPATE_HISTORY_LIMIT);
    }

    public static int getServeFoodTableSingleSeat(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_PARTICPATE_COOKING_SINGLE_MAX_NUM")){
                return Integer.valueOf(configMap.get("COOKBOY_PARTICPATE_COOKING_SINGLE_MAX_NUM").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_PARTICPATE_COOKING_SINGLE_MAX_NUM);
    }

    public static int getServeFoodTableSeat(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_PARTICPATE_COOKING_MAX_NUM")){
                return Integer.valueOf(configMap.get("COOKBOY_PARTICPATE_COOKING_MAX_NUM").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_PARTICPATE_COOKING_MAX_NUM);
    }

    public static int getServeDishTableSeat(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_PARTICPATE_COOKING_MAX_NUM")){
                return Integer.valueOf(configMap.get("COOKBOY_PARTICPATE_COOKING_MAX_NUM").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_PARTICPATE_COOKING_MAX_NUM);
    }

    public static int getServeFoodTableTime(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_PARTICPATE_COOKING_TIME")){
                return Integer.valueOf(configMap.get("COOKBOY_PARTICPATE_COOKING_TIME").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_PARTICPATE_COOKING_TIME);
    }

    public static int getServeDishTableTime(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_PARTICPATE_COOKING_TIME")){
                return Integer.valueOf(configMap.get("COOKBOY2_PARTICPATE_COOKING_TIME").getValue());
            }
        }
        return Integer.valueOf(COOKBOY2_PARTICPATE_COOKING_TIME);
    }

    public static int getServeFoodStartHour(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_SERVE_FOOD_DAY_START")){
                return Integer.valueOf(configMap.get("COOKBOY_SERVE_FOOD_DAY_START").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_SERVE_FOOD_DAY_START);
    }

    public static int getServeDishStartHour(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_SERVE_FOOD_DAY_START")){
                return Integer.valueOf(configMap.get("COOKBOY2_SERVE_FOOD_DAY_START").getValue());
            }
        }
        return Integer.valueOf(COOKBOY2_SERVE_FOOD_DAY_START);
    }


    public static int getServeBanquetStartHour(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY3_SERVE_FOOD_DAY_START")){
                return Integer.valueOf(configMap.get("COOKBOY3_SERVE_FOOD_DAY_START").getValue());
            }
        }
        return Integer.valueOf(COOKBOY3_SERVE_FOOD_DAY_START);
    }

    public static int getServeFoodEndHour(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY_SERVE_FOOD_DAY_END")){
                return Integer.valueOf(configMap.get("COOKBOY_SERVE_FOOD_DAY_END").getValue());
            }
        }
        return Integer.valueOf(COOKBOY_SERVE_FOOD_DAY_END);
    }

    public static int getServeDishEndHour(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_SERVE_FOOD_DAY_END")){
                return Integer.valueOf(configMap.get("COOKBOY2_SERVE_FOOD_DAY_END").getValue());
            }
        }
        return Integer.valueOf(COOKBOY2_SERVE_FOOD_DAY_END);
    }

    public static int getServeBanquetEndHour(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY3_SERVE_FOOD_DAY_END")){
                return Integer.valueOf(configMap.get("COOKBOY3_SERVE_FOOD_DAY_END").getValue());
            }
        }
        return Integer.valueOf(COOKBOY3_SERVE_FOOD_DAY_END);
    }

    public static boolean isTimeInMatchTime(ActivityInfo activityInfo,long timeStamp){
        if(activityInfo.getChildType() == eActivityCookBoyType.Process1.getChildType()){
            int hour = DateHelper.getTimeStampHours(timeStamp);
            //早上10点到晚上10点才会进行
            if(hour >= getServeFoodStartHour(activityInfo.getActivityId()) && hour < getServeFoodEndHour(activityInfo.getActivityId())){
                return true;
            }
        }
        return false;
    }

    public static boolean isActivityMatchTime(ActivityInfo activityInfo){
        if(null == activityInfo){
            return false;
        }
        long nowTime = System.currentTimeMillis() / 1000;
        if(nowTime < activityInfo.getBeginTime() || nowTime > activityInfo.getEndTime()){
            return false;
        }
        int nowHour = DateHelper.getHours();
        if(activityInfo.getChildType() == eActivityCookBoyType.Process1.getChildType()){
            //早上10点到晚上10点才会进行
            if(nowHour < getServeFoodStartHour(activityInfo.getActivityId()) || nowHour >= getServeFoodEndHour(activityInfo.getActivityId())){
                return false;
            }
        }else if(activityInfo.getChildType() == eActivityCookBoyType.Process2.getChildType()){
            //早上10点到晚上10点才会进行
            /*if(nowHour < getServeDishStartHour(activityInfo.getActivityId()) || nowHour >= getServeDishEndHour(activityInfo.getActivityId())){
                return false;
            }*/
        }else if(activityInfo.getChildType() == eActivityCookBoyType.Process3.getChildType()){
            //早上10点到晚上10点才会进行
            /*if(nowHour < getServeBanquetStartHour(activityInfo.getActivityId()) || nowHour >= getServeBanquetEndHour(activityInfo.getActivityId())){
                return false;
            }*/
        }
        return true;
    }

    public static void addChildConditionType(Map<Integer,ActivityInfo> activityInfoMap){
        for(ActivityInfo activityInfo : activityInfoMap.values()){
            if(activityInfo.getChildType() == eActivityCookBoyType.Process1.getChildType()){
                Map<Integer,Integer> tempMap = new ConcurrentHashMap<>();
                tempMap.put(CrossRelationActivityMgr.EVENT_RANK_USER_TYPE, eGamePlayerEventType.CookBoy1IntegralUserCrossRank.getValue());
                tempMap.put(CrossRelationActivityMgr.EVENT_RANK_UNION_TYPE, eGamePlayerEventType.CookBoy1IntegralUnionCrossRank.getValue());
                tempMap.put(CrossRelationActivityMgr.EVENT_RANK_SERVER_TYPE, eGamePlayerEventType.CookBoy1IntegralServerCrossRank.getValue());
                addConditionType(activityInfo.getActivityId(),tempMap);
            }
            if(activityInfo.getChildType() == eActivityCookBoyType.Process2.getChildType()){
                Map<Integer,Integer> tempMap = new ConcurrentHashMap<>();
                tempMap.put(CrossRelationActivityMgr.EVENT_RANK_USER_TYPE, eGamePlayerEventType.CookBoy2IntegralUserCrossRank.getValue());
                addConditionType(activityInfo.getActivityId(),tempMap);
            }
            if(activityInfo.getChildType() == eActivityCookBoyType.Process3.getChildType()){
                Map<Integer,Integer> tempMap = new ConcurrentHashMap<>();
                tempMap.put(CrossRelationActivityMgr.EVENT_RANK_USER_TYPE, eGamePlayerEventType.CookBoy3IntegralUserCrossRank.getValue());
                addConditionType(activityInfo.getActivityId(),tempMap);
            }
        }
    }

    public static void loadChildActivity(Map<Integer,ActivityInfo> activityInfoMap){
        Map<Integer,ActivityInfo> cookBoyAcMap = new ConcurrentHashMap<>();
        List<Integer> activityIdList = new ArrayList<>();
        for (ActivityInfo activityInfo : activityInfoMap.values()) {
            if(activityInfo.getType() == eActivityType.CookingBoyActivity.getValue()){
                activityIdList.add(activityInfo.getActivityId());
                cookBoyAcMap.put(activityInfo.getActivityId(),activityInfo);
            }
        }
        Map<Integer, Map<String, CookBoyConfig>> tempActivityCookBoyConfigMap = ActivityBussiness.getCookBoyActivityConfig(activityIdList);
        Map<Integer, Map<Integer, CookBoy2DishConfig>> tempActivityCookBoy2DishConfigMap = ActivityBussiness.getCookBoy2ActivityDishConfig(activityIdList);

        //读取其他活动配置
        for(int activityId : tempActivityCookBoyConfigMap.keySet()){
            cookBoyConfigMap.put(activityId,tempActivityCookBoyConfigMap.get(activityId));
        }
        for(int activityId : tempActivityCookBoy2DishConfigMap.keySet()){
            cookBoyDishConfigMap.put(activityId,tempActivityCookBoy2DishConfigMap.get(activityId));
        }

        //调用子类的初始化
        for(ActivityInfo activityInfo : activityInfoMap.values()){
            loadNewActivity(activityInfo);
        }
        CrossCookBoyMgr.removeActivity();
        addChildConditionType(cookBoyAcMap);
    }

    private static void loadNewActivity(ActivityInfo activityInfo) {
        int activityId = activityInfo.getActivityId();
        int type = activityInfo.getType();
        int childType = activityInfo.getChildType();
        if (type == eActivityType.CookingBoyActivity.getValue()) {
            CrossCookBoyMgr.loadActivity(activityId);
        }
    }

    public static int getCookBoy2IntegralItemId(int activityId){
        if(cookBoyConfigMap.containsKey(activityId)){
            Map<String,CookBoyConfig> configMap = cookBoyConfigMap.get(activityId);
            if(configMap.containsKey("COOKBOY2_EXCHANGE_ITEM_ID")){
                return Integer.parseInt(configMap.get("COOKBOY2_EXCHANGE_ITEM_ID").getValue());
            }
        }
        return Integer.parseInt(COOKBOY2_EXCHANGE_ITEM_ID);
    }

    @Override
    public boolean reload() {
        return true;
    }
}
